#include "LDFactory.h"
#include "VC220.h"

using namespace Utility::LoggerLib;

CLDFactory::CLDFactory()
{
	m_pLD = NULL;
}

CLDFactory::~CLDFactory()
{
	if (NULL != m_pLD)
	{
		delete m_pLD;
	}
}

CLineDisplay* CLDFactory::CreateInstance(int nPort, int nParity /* = 2 */, int nBaud /* = 9600 */, ELineDisplayType eType /* = VC220 */)
{
	if (NULL == m_pLD)
	{
		switch (eType)
		{
		case  VC220:
			m_pLD = new CLD_VC220();
			m_pLD->InitPort(nPort, nParity, nBaud, eType);
			break;
		default:
			Log(ERROR_LEVEL, ELineDisplay, L"Unkown linedisplay type: %d!", eType);
			break;
		}
	}

	return m_pLD;
}